home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 June / PCpro_2006_06.ISO / files / freeware / openvip.exe / {app} / TransitionPanel.py < prev    next >
Encoding:
Python Source  |  2003-06-18  |  6.4 KB  |  150 lines

  1. #
  2. # This file is part of OpenVIP (http://openvip.sourceforge.net)
  3. #
  4. # Copyright (C) 2002-2003
  5. # Michal Dvorak, Jiri Sedlar, Antonin Slavik, Vaclav Slavik, Jozef Smizansky
  6. #
  7. # This program is licensed under GNU General Public License version 2;
  8. # see file COPYING in the top level directory for details.
  9. #
  10. # $Id: TransitionPanel.py,v 1.12 2003/06/18 16:55:08 vaclavslavik Exp $
  11. #
  12.  
  13. from wxPython.wx import *
  14. import globals, openvip, notify, worker
  15. from ATransitionSettingsDialog import ATransitionSettingsDialog
  16. from VTransitionSettingsDialog import VTransitionSettingsDialog
  17.  
  18. ID_LISTBOX = wxNewId()
  19. ID_PARAMS = wxNewId()
  20. ID_UP = wxNewId()
  21. ID_DOWN = wxNewId()
  22.  
  23. class TransitionPanel(wxPanel):
  24.     """This class implements ObjectPanel's content for transitions on
  25.        timeline. It shows list of available transitions and lets the user
  26.        select one of them. Buttons for setting transition direction (A->B
  27.        or B->A) and setting its parameters (by launching
  28.        VTransitionSettingsDialog or ATransitionSettingsDialog) are provided as
  29.        well."""
  30.     def __init__(self, *args, **kwds):
  31.         # begin wxGlade: TransitionPanel.__init__
  32.         kwds["style"] = wxTAB_TRAVERSAL
  33.         wxPanel.__init__(self, *args, **kwds)
  34.         self.transition_text = wxTextCtrl(self, -1, "", style=wxTE_READONLY)
  35.         self.direction_up = wxBitmapButton(self, ID_UP, wxBitmap("bitmaps/arrow_up.png", wxBITMAP_TYPE_PNG))
  36.         self.direction_down = wxBitmapButton(self, ID_DOWN, wxBitmap("bitmaps/arrow_down.png", wxBITMAP_TYPE_PNG))
  37.         self.settings = wxBitmapButton(self, ID_PARAMS, wxBitmap("bitmaps/filter_settings.png", wxBITMAP_TYPE_PNG))
  38.         self.label_3 = wxStaticText(self, -1, "Available transitions:", style=wxALIGN_CENTRE)
  39.         self.listbox = wxListBox(self, ID_LISTBOX, choices=["choice 1"])
  40.  
  41.         self.__set_properties()
  42.         self.__do_layout()
  43.         # end wxGlade
  44.         
  45.         lib = globals.core
  46.         self.video_transitions = lib.enum_plugins(openvip.PLUGIN_VIDEO_TRANSITION)
  47.         self.audio_transitions = lib.enum_plugins(openvip.PLUGIN_AUDIO_TRANSITION)
  48.         self.video_transitions_desc2name = dict([(p.description, p.name) for p in self.video_transitions])
  49.         self.video_transitions_name2desc = dict([(p.name, p.description) for p in self.video_transitions])
  50.         self.audio_transitions_desc2name = dict([(p.description, p.name) for p in self.audio_transitions])
  51.         self.audio_transitions_name2desc = dict([(p.name, p.description) for p in self.audio_transitions])
  52.         EVT_LISTBOX_DCLICK(self, ID_LISTBOX, self.OnChange)
  53.         EVT_BUTTON(self, ID_PARAMS, self.OnParams)
  54.         EVT_BUTTON(self, ID_UP, self.OnDirUp)
  55.         EVT_BUTTON(self, ID_DOWN, self.OnDirDown)
  56.         self.current_trans=''
  57.  
  58.     def __set_properties(self):
  59.         # begin wxGlade: TransitionPanel.__set_properties
  60.         self.direction_up.SetSize((32, 32))
  61.         self.direction_up.SetToolTipString("Transition direction up")
  62.         self.direction_down.SetSize((32, 32))
  63.         self.direction_down.SetToolTipString("Transition direction down")
  64.         self.settings.SetSize((32, 32))
  65.         self.settings.SetToolTipString("Transition settings")
  66.         self.listbox.SetSelection(0)
  67.         # end wxGlade
  68.  
  69.     def __do_layout(self):
  70.         # begin wxGlade: TransitionPanel.__do_layout
  71.         sizer_2 = wxBoxSizer(wxHORIZONTAL)
  72.         sizer_1 = wxBoxSizer(wxVERTICAL)
  73.         sizer_3 = wxBoxSizer(wxHORIZONTAL)
  74.         sizer_1.Add(self.transition_text, 0, wxALL|wxEXPAND, 5)
  75.         sizer_3.Add(20, 20, 1, wxEXPAND, 0)
  76.         sizer_3.Add(self.direction_up, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_HORIZONTAL, 5)
  77.         sizer_3.Add(self.direction_down, 0, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5)
  78.         sizer_3.Add(self.settings, 0, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5)
  79.         sizer_3.Add(20, 20, 1, wxEXPAND, 0)
  80.         sizer_1.Add(sizer_3, 0, wxEXPAND, 0)
  81.         sizer_1.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 10)
  82.         sizer_1.Add(self.listbox, 1, wxALL|wxEXPAND, 5)
  83.         sizer_2.Add(sizer_1, 1, wxEXPAND, 0)
  84.         self.SetAutoLayout(1)
  85.         self.SetSizer(sizer_2)
  86.         sizer_2.Fit(self)
  87.         sizer_2.SetSizeHints(self)
  88.         self.Layout()
  89.         # end wxGlade
  90.  
  91.     def Update(self):
  92.         self.transition_text.SetLabel(self.transitions_name2desc[self.object.name])
  93.  
  94.     def OnChange(self, event):
  95.         f = self.listbox.GetSelection()
  96.         if f>=0:
  97.             self.object.name=self.transitions_desc2name[self.listbox.GetString(f)]
  98.             self.object.params={}
  99.             self.transition_text.SetLabel(self.listbox.GetString(f))
  100.             self.OnParams(None)
  101.                 
  102.     def OnParams(self, event):
  103.         if self.object.track[0]=='V':
  104.             dlg = VTransitionSettingsDialog(self, -1, "")
  105.         else:
  106.             dlg = ATransitionSettingsDialog(self, -1, "")
  107.         dlg.SetObject(self.model, self.object)
  108.         if dlg.LoadContent(self.object.name):
  109.             dlg.SetParams(self.object.params)
  110.             dlg.Centre()
  111.             retval = dlg.ShowModal()
  112.             dlg.WaitUntilNotUsed()
  113.             if (retval == wxID_OK):
  114.                 self.object.params=dlg.GetParams()
  115.                 self.Update()
  116.                 notify.notify(self.model)
  117.             else:
  118.                 dlg.Destroy()
  119.  
  120.     def OnDirUp(self, event):
  121.         self.object.direction='BA'
  122.         notify.notify(self.model)
  123.  
  124.     def OnDirDown(self, event):
  125.         self.object.direction='AB'
  126.         notify.notify(self.model)
  127.  
  128.     def SetObject(self, modl, obj):
  129.         """Called when selection changes on TimelineWidget to let the panel
  130.            redraw itself to display obj (a model.Transition instance)
  131.            transition."""
  132.         self.model = modl
  133.         self.object = obj
  134.         self.listbox.Clear()
  135.         if obj.track[0]=='V':   # video transition
  136.             for p in self.video_transitions:
  137.                 self.listbox.Append(p.description)
  138.             self.transitions_desc2name=self.video_transitions_desc2name
  139.             self.transitions_name2desc=self.video_transitions_name2desc
  140.         elif obj.track[0]=='A':     # object on audio track - display all audio filters
  141.             for p in self.audio_transitions:
  142.                 self.listbox.Append(p.description)
  143.             self.transitions_desc2name=self.audio_transitions_desc2name
  144.             self.transitions_name2desc=self.audio_transitions_name2desc
  145.         self.Update()
  146.  
  147. # end of class TransitionPanel
  148.  
  149.  
  150.